﻿@{
    ViewBag.Title = "MSettingForm";
    Layout = "~/Views/Shared/_LayoutIndex.cshtml";
}

<script>
    $(function () {
        GetGrid();
    });
    //加载表格
    function GetGrid() {
        var selectedRowIndex = 0;
        var $gridTable = $('#gridTable2');
        $gridTable.jqGrid({
            url: "../../QualificationManage/FirstTrial/GetMaterialRuleList",
            datatype: "json",
            height: $(window).height() - 100,
            autowidth: true,
            colModel: [
                { label: "Code", name: "Code", index: "Code", width: 80, align: "center", hidden: true },
                { label: "排序", name: "Sort", index: "Sort", width: 80, align: "center" },
                { label: "名称", name: "Name", index: "Name", width: 120, align: "center" },
                { label: "标准说明", name: "Description", Description: "Description", width: 400, align: "center" },
                {
                    label: "是否提交", name: "IsSubmit", index: "IsRequired", width: 80, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return "是";
                        }
                        else {
                            return "否";
                        }
                    }
                },
                 {
                     label: "是否上传", name: "IsUpload", index: "IsUpload", width: 80, align: "center",
                     formatter: function (cellvalue, options, rowObject) {
                         if (cellvalue == 1) {
                             return "是";
                         }
                         else {
                             return "否";
                         }
                     }
                 },
                {
                    label: "是否有效", name: "EnabledMark", index: "EnabledMark", width: 80, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return "是";
                        }
                        else {
                            return "否";
                        }
                    }
                },
               // { label: "示例图片", name: "DemoImage", index: "Area", width: 80, align: "DemoImage" },
                { label: "创建人", name: "CreateUserName", index: "CreateUserName", width: 80, align: "left" },
                { label: "创建时间", name: "CreateDate", index: "CreateDate", width: 80, align: "left" }
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager",
            sortname: 'Date',
            sortorder: 'desc',
            shrinkToFit: false,
            gridview: true,
            onSelectRow: function () {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });

    }

    //编辑
    function btn_edit() {
        var keyValue = $("#gridTable2").jqGridRowValue("Code");
        if (checkedRow(keyValue)) {
            dialogOpen({
                id: "AddForm",
                title: '编辑',
                url: '/QualificationManage/FirstTrial/AddForm?keyValue=' + keyValue,
                width: "700px",
                height: "430px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick();
                }
            });

        }
    }
    //删除
    function btn_delete() {
        var keyValue = $("#gridTable2").jqGridRowValue("Code");
        if (checkedRow(keyValue)) {
            $.RemoveForm({
                url: '/QualificationManage/FirstTrial/RemoveMaterialRuleEntity',
                param: { keyValue: keyValue },
                success: function (data) {
                    document.location.reload();
                }
            })
        }
    }

    //新增
    function btn_AddMaterial() {
        dialogOpen({
            id: "AddForm",
            title: '添加',
            url: '/QualificationManage/FirstTrial/AddForm',
            width: "550px",
            height: "400px",
            callBack: function (iframeId) {
                top.frames[iframeId].AcceptClick();
            }
        });
    }
    function AcceptClick() {
        dialogClose();
    }
</script>

<div class="titlePanel">
    <div class="title-search">
        <div class="toolbar">
            <div class="btn-group">
                <a id="lr-addMaterial" class="btn btn-default" onclick="btn_AddMaterial()"><i class="fa fa-plus"></i>&nbsp;新增</a>
                <a id="lr-editMaterial" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
                <a id="lr-deleteMaterial" class="btn btn-default" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
            </div>
            <script>$('.toolbar').authorizeButton()</script>
        </div>
    </div>
</div>
<div class="gridPanel">
    <table id="gridTable2"></table>
</div>

